<template>
  <a-menu v-model="current" mode="inline" :defaultOpenKeys="keys">
    <a-menu-item key="/device" @click="handle">
      <a-icon type="pie-chart" />
      <span>设备管理</span>
    </a-menu-item>
    <a-sub-menu key="1">
      <span slot="title"><a-icon type="mail" /><span>广告位管理</span></span>
      <a-menu-item key="/AD/list" @click="handle">广告位列表</a-menu-item>
      <a-menu-item key="/AD/manage" @click="handle">新增广告位</a-menu-item>
    </a-sub-menu>
  </a-menu>
</template>

<script>
import menu from "../menu";
export default {
  data() {
    return {
      current: ["/device"],
      keys:[]
    };
  },
  created() {
    this.current = [location.hash.slice(1)]
    if(location.hash.slice(1).startsWith('/AD')){
      this.keys = ['1']
    }else{
      this.keys = []
    }
  },
  methods: {
    handle({ key }) {
      this.$router.push(key);
    },
  },
};
</script>